package com.ruoyi.business.question;

import com.ruoyi.business.domain.Question;
import com.ruoyi.business.domain.bo.QuestionBo;
import com.ruoyi.business.domain.vo.QuestionVo;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.bean.BeanUtils;

import java.util.List;

/**
 * @author 最爱喝兽奶
 * @create 2022/8/9
 **/
public class FillQuestionHandle extends AbstractQuestionHandle implements QuestionHandle {

    public FillQuestionHandle() {
        super();
    }

    @Override
    public Question insertAnswer(QuestionBo bo, Question question) {
        if (StringUtils.isBlank(question.getAnswer())) {
            question.setAnswer(bo.getAnswerImport());
        }
        return question;
    }

    @Override
    public QuestionVo queryResult(Question question) {
        QuestionVo vo = new QuestionVo();
        BeanUtils.copyBeanProp(vo, question, true);
        return vo;
    }

    @Override
    public void deleteQuestion(String id) {
        super.deleteQuestion(id);
    }

    @Override
    public Integer calcScore(String answer, String questionId, Integer score) {
        return super.calcScore(answer, questionId, score);
    }


    @Override
    public List<String> randQueryQuestionByType(String courseId, int limit) {
        return questionMapper.randQueryQuestionByType(courseId, QuestionHandleFactory.FILL_QUESTION, limit);
    }
}
